﻿/*----------------------------------------------------------------
       // Copyright (C) 2008 安华顺通(北京)科技有限公司
       // 版权所有。 
       //
       // 文件名：SysCollection.cs
       // 文件功能描述：属性中所有下拉列表框的实现。
       //
       // 
       // 创建标识：杨波
       //
       // 修改标识：
       // 修改描述：
       //
       // 修改标识：
       // 修改描述：
//----------------------------------------------------------------*/

#region UsingStatements

using System.ComponentModel;

#endregion

namespace RuleCode.ObjectTree
{
    /// <summary>
    /// BaseCollection类是所有属性下拉列表框的基类。
    /// </summary>
    public class BaseCollection : StringConverter
    {
        protected StandardValuesCollection value;


        public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
        {
            return true;
        }

        public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
        {
            return true;
        }
    }
    //属性下拉列表框的优化基类，子类中重写SetStandardValuesCollection虚方法，填入列表数据。
    public class AdvBaseStringCollection : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            SetStandardValuesCollection();
            return value;
        }
        protected virtual void SetStandardValuesCollection()
        {

        }
    }
    public class TableCollection : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                //if (value == null)
                /*{
                    string[] strs = new string[3];
                    strs[0] = "China";
                    strs[1] = "USA";
                    strs[2] = "Germany";
                    value = new StandardValuesCollection(strs);
                }*/
                //value = new TypeConverter.StandardValuesCollection(new string[] { "China", "USA", "Germany" });
                value = new StandardValuesCollection(ObjectList.Instance.TableList);

                return value;
            }
        }
    }

    public class TableFieldCollection : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                //if (value == null || ObjectList.Instance.GetTypeExpire(OT.Table))
                //{
                value = new StandardValuesCollection(ObjectList.Instance.TableFieldList);
                //}
                return value;
            }
        }
    }

    public class TableGroupFieldPropertyList : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null || ObjectList.Instance.GetTypeExpire(OT.TableFieldGroupField))
                {
                    value = new StandardValuesCollection(ObjectList.Instance.TableGroupFieldPropertyFieldsList);
                }
                return value;
            }
        }
    }

    public class TableRelationField : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null || ObjectList.Instance.GetTypeExpire(OT.TableRelationField))
                {
                    value = new StandardValuesCollection(ObjectList.Instance.TableRelationField);
                }
                return value;
            }
        }
    }

    public class TableRelationRelatedField : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null || ObjectList.Instance.GetTypeExpire(OT.TableRelationRelatedField))
                {
                    value = new StandardValuesCollection(ObjectList.Instance.TableRelationRelatedField);
                }
                return value;
            }
        }
    }
    public class TableGroup : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null || ObjectList.Instance.GetTypeExpire(OT.TableRelationRelatedField))
                {
                    value = new StandardValuesCollection(ObjectList.Instance.TableGroupList);
                }
                return value;
            }
        }
    }
    public class WebFormFieldGroupCollection : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
               // if (value == null || ObjectList.Instance.GetTypeExpire(OT.TableRelationRelatedField))
                {
                    value = new StandardValuesCollection(ObjectList.Instance.WebFormFieldGroupList);
                }
                return value;
            }
        }
    }
    public class AlignmentCollection : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value =
                        new StandardValuesCollection(new[]
                                                         {
                                                             PropertyValue.Auto, PropertyValue.Left,
                                                             PropertyValue.Right,
                                                             PropertyValue.Center
                                                         });
                }
                return value;
            }
        }
    }

    public class TableDeleteAction : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value =
                        new StandardValuesCollection(new[]
                                                         {
                                                             PropertyValue.None, PropertyValue.Restrict,
                                                             PropertyValue.Cascade, PropertyValue.CascadeAndRestrict
                                                         });
                }
                return value;
            }
        }
    }

    public class BaseEnumStyle : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value = new StandardValuesCollection(new[] { PropertyValue.ComboBox, PropertyValue.RadioButton });
                }
                return value;
            }
        }
    }

    public class NeededAcessLevel : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value =
                        new StandardValuesCollection(new[]
                                                         {
                                                             PropertyValue.NoAccess, PropertyValue.View,
                                                             PropertyValue.Edit
                                                             , PropertyValue.Add, PropertyValue.Delete
                                                         });
                }
                return value;
            }
        }
    }

    public class TableFieldUpdate : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value = new StandardValuesCollection(new[] { PropertyValue.Absolute, PropertyValue.Relative });
                }
                return value;
            }
        }
    }

    public class EDTButtonImage : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value =
                        new StandardValuesCollection(new[]
                                                         {
                                                             PropertyValue.Arrow, PropertyValue.Mail,
                                                             PropertyValue.URL, PropertyValue.ThreeDots,
                                                             PropertyValue.OpenFile, PropertyValue.Calendar,
                                                             PropertyValue.Phone
                                                         });
                }
                return value;
            }
        }
    }

    public class EDTStringChangeCase : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value =
                        new StandardValuesCollection(new[]
                                                         {
                                                             PropertyValue.Auto, PropertyValue.None,
                                                             PropertyValue.UPPER_CASE, PropertyValue.lower_case,
                                                             PropertyValue.SentenceCase
                                                         });
                }
                return value;
            }
        }
    }

    public class EDTIntSignDisplay : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value =
                        new StandardValuesCollection(new[]
                                                         {
                                                             PropertyValue.Auto, PropertyValue.None,
                                                             PropertyValue.Prefixed
                                                             , PropertyValue.Suffixed
                                                         });
                }
                return value;
            }
        }
    }

    public class AutoYesNoProperty : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value =
                        new StandardValuesCollection(new[] { PropertyValue.Auto, PropertyValue.Yes, PropertyValue.No });
                }
                return value;
            }
        }
    }

    public class EDTIntRotateSign : AutoYesNoProperty
    {
    }

    public class EDTIntShowZero : AutoYesNoProperty
    {
    }

    public class EDTIntAllowNagative : AutoYesNoProperty
    {
    }

    public class EDTRealThousandSeparator : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value =
                        new StandardValuesCollection(new[]
                                                         {
                                                             PropertyValue.Auto, PropertyValue.None, PropertyValue.Comma
                                                             ,
                                                             PropertyValue.Dot, PropertyValue.Apostrophe,
                                                             PropertyValue.Space
                                                         });
                }
                return value;
            }
        }
    }

    public class EDTRealDecimalSeparator : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value =
                        new StandardValuesCollection(new[] { PropertyValue.Auto, PropertyValue.Comma, PropertyValue.Dot });
                }
                return value;
            }
        }
    }

    public class EDTRealInsSeparator : AutoYesNoProperty
    {
    }

    public class EDTRealFormatMST : AutoYesNoProperty
    {
    }

    public class TableContent : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value =
                        new StandardValuesCollection(new[]
                                                         {
                                                             PropertyValue.NotSpecified, PropertyValue.BaseData,
                                                             PropertyValue.DefaultData, PropertyValue.BaseAndDefaultData
                                                         });
                }
                return value;
            }
        }
    }

    public class MaxAccessMode : NeededAcessLevel
    {
    }

    public class TableCacheLookUp : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value = new StandardValuesCollection(new[] { PropertyValue.None, PropertyValue.EntireTable });
                }
                return value;
            }
        }
    }

    public class FormDesignFrameStyle : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value =
                        new StandardValuesCollection(new[]
                                                         {
                                                             PropertyValue.None, PropertyValue.Standard,
                                                             PropertyValue.Border, PropertyValue.Dialog
                                                         });
                }
                return value;
            }
        }
    }

    public class FormDesignWindowResize : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value =
                        new StandardValuesCollection(new[]
                                                         {
                                                             PropertyValue.Auto, PropertyValue.Dynamic,
                                                             PropertyValue.Fixed
                                                         });
                }
                return value;
            }
        }
    }

    public class FormDesignWindowType : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value = new StandardValuesCollection(new[] { PropertyValue.Standard, PropertyValue.Popup });
                }
                return value;
            }
        }
    }

    public class ColorScheme : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value =
                        new StandardValuesCollection(new[]
                                                         {
                                                             PropertyValue.Default, PropertyValue.RGB,
                                                             PropertyValue.WindowsPalette
                                                         });
                }
                return value;
            }
        }
    }

    public class FormDesignImageMode : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value =
                        new StandardValuesCollection(new[]
                                                         {
                                                             PropertyValue.Normal, PropertyValue.SideToFit,
                                                             PropertyValue.SideBySide, PropertyValue.Center
                                                         });
                }
                return value;
            }
        }
    }

    public class FormDesignMode : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value =
                        new StandardValuesCollection(new[]
                                                         {
                                                             PropertyValue.Watch, PropertyValue.Edit, PropertyValue.Add,
                                                             PropertyValue.Delete
                                                         });
                }
                return value;
            }
        }
    }

    public class FormDesignArrangeWhen : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value =
                        new StandardValuesCollection(new[]
                                                         {
                                                             PropertyValue.Default, PropertyValue.Auto,
                                                             PropertyValue.StartUp, PropertyValue.OnDemand,
                                                             PropertyValue.Never
                                                         });
                }
                return value;
            }
        }
    }

    public class FormDesignArrangeMothed : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value = new StandardValuesCollection(new[] { PropertyValue.Vertical, PropertyValue.Horizontal });
                }
                return value;
            }
        }
    }

    public class QueryLiterals : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value =
                        new StandardValuesCollection(new[]
                                                         {
                                                             PropertyValue.Default, PropertyValue.ForceLiterals,
                                                             PropertyValue.ForcePlaceholders
                                                         });
                }
                return value;
            }
        }
    }

    public class QueryDataSourceAllowAdd : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value = new StandardValuesCollection(new[] { PropertyValue.AllFields, PropertyValue.NoFields });
                }
                return value;
            }
        }
    }

    public class QueryDataSourceOrderMode : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value = new StandardValuesCollection(new[] { PropertyValue.OrderBy, PropertyValue.GroupBy });
                }
                return value;
            }
        }
    }

    public class QueryDataSourceFieldSortingMode : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value = new StandardValuesCollection(new[] { PropertyValue.Ascending, PropertyValue.Descending });
                }
                return value;
            }
        }
    }

    public class QueryDataSourceRangeStatusMode : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value =
                        new StandardValuesCollection(new[] { PropertyValue.Open, PropertyValue.Lock, PropertyValue.Hide });
                }
                return value;
            }
        }
    }

    public class QueryDataSourceTableFieldsList : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value = new StandardValuesCollection(ObjectList.Instance.QueryDataSourceTableFields);
                }
                return value;
            }
        }
    }

    public class ControlLeftList : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value =
                        new StandardValuesCollection(new[]
                                                         {
                                                             PropertyValue.AutoLeft, PropertyValue.AutoRight,
                                                             PropertyValue.LeftEdge, PropertyValue.RightEdge,
                                                             PropertyValue.Center
                                                         });
                }
                return value;
            }
        }
    }

    public class ControlTopList : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value =
                        new StandardValuesCollection(new[]
                                                         {
                                                             PropertyValue.Auto, PropertyValue.TopEdge,
                                                             PropertyValue.BottomEdge, PropertyValue.Center
                                                         });
                }
                return value;
            }
        }
    }

    public class ControlWidthAndHeightList : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value = new StandardValuesCollection(new[] { PropertyValue.Auto, PropertyValue.ColumnWidth });
                }
                return value;
            }
        }
    }

    public class ControlDragDropList : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value = new StandardValuesCollection(new[] { PropertyValue.None, PropertyValue.Manaul });
                }
                return value;
            }
        }
    }

    public class ButtonDisplayList : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value = new StandardValuesCollection(new[] { PropertyValue.Text, PropertyValue.Image });
                }
                return value;
            }
        }
    }

    public class BackStyle : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value = new StandardValuesCollection(new[] { PropertyValue.Opaque, PropertyValue.Transparent });
                }
                return value;
            }
        }
    }

    public class MenuItemTypeCollection : BaseCollection
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            return Values;
        }

        public StandardValuesCollection Values
        {
            get
            {
                if (value == null)
                {
                    value =
                        new StandardValuesCollection(new[]
                                                         {
                                                             PropertyValue.Display, PropertyValue.Output,
                                                             PropertyValue.Action
                                                         });
                }
                return value;
            }
        }
    }
    public class EnumTypeCollection : AdvBaseStringCollection
    {
        protected override void SetStandardValuesCollection()
        {
            if (value == null || ObjectList.Instance.GetTypeExpire(OT.BaseEnums))
            {
                value = new StandardValuesCollection(ObjectList.Instance.EnumList);
            }

            base.SetStandardValuesCollection();

        }
    }
}